<?php 
// ini_set('display_errors', 'On');
// error_reporting(E_ALL);
$sql="select a.id,a.info_id,a.need_num,a.rate,a.join_num,a.words,a.qihao,(a.need_num-a.join_num) as left_num,a.goods_id,b.name,b.icon,b.icon_pc,b.typeid,b.ontime,b.push from ttdb.activity_hot as a
    left join ttdb.goods as b on a.goods_id=b.id
    left join ttdbduiba.duibaitem as c on b.duibaid=c.id
    where a.dstatus=2 and (c.dtype!=9 OR c.dtype is null) and b.typeid=5 and a.need_num != a.join_num order by b.ontime desc";

$query = exec_db_126($sql);
while ($value = mysqli_fetch_array($query,MYSQL_ASSOC))
{
	if(!iscar($value['goods_id']))
	{
		if($value['icon_pc'])
		{
			$value['icon']=$value['icon_pc'];
		}
		$http=substr($value['icon'],0,4);
		if($http != 'http')
		{
			$value['icon'] = 'http://img1.ttdb.com'.$value['icon'];
		}
		$need_num=$value['need_num'];
		$join_num=$value['join_num'];
		$per = sprintf("%.2f",($join_num/$need_num)*100);
		$value['join_per']=$per;
		if($value['goods_id']==114 || $value['goods_id']==115 || $value['goods_id']==116)
		{
			$value['typeid']=11;
		}
		$list[$value['goods_id']] = $value;
	}
}
$content='<?php ';
$content .= "\$list = ". var_export($list,true) . ";\r\n";
$content .= ' ?>';
file_put_contents(S_ROOT.'source/data/duobaogoods.php',$content);

function iscar($goods_id)
{
	if(in_array($goods_id,array(104,106,107,108,254,255,335,435,436,552,841)))
	{
		return true;
	}
	return false;
}
?>